package com.zqu.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zqu.pojo.LostClient;
import com.zqu.service.LostClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("lostclient")
public class LostClientController {
    @Autowired
    private LostClientService lostClientService;

    @RequestMapping("findlostclient")
    @ResponseBody
    public LostClient selectById(long id){
        return lostClientService.selectLostClientById(id);
    }

    @RequestMapping("selectlostclientlist")
    @ResponseBody
    public PageInfo<LostClient> selectList(Integer pageNo, Integer pageSize){
        if(pageNo==null){
            pageNo=1;
        }
        if (pageSize==null){
            pageSize=5;
        }
        PageHelper.startPage(pageNo,pageSize);
        List<LostClient> list = lostClientService.selectList(new LostClient());
        PageInfo<LostClient> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @RequestMapping("insertlostclient")
    @ResponseBody
    public boolean insert(){
        return lostClientService.insertLostClient(new LostClient());
    }

    @RequestMapping("updatelostclient")
    @ResponseBody
    public boolean update(){
        return lostClientService.updateLostClient(new LostClient());
    }

    @RequestMapping("deletelostclient")
    @ResponseBody
    public boolean delete(long id){
        return lostClientService.deleteLostClient(id);
    }

    @RequestMapping("deletelostclientbyids")
    @ResponseBody
    public boolean deleteByIds(String[] ids){
        return lostClientService.deleteLostClientByIds(ids);
    }
}
